package com.aramco.fion.vo
{

	public class dateVO
	{
		public function dateVO(value:String)
		{
			this.value = value;
		}
		
		private var _value:String;
		
		
		public function get value():String
		{
			return _value;
		}

		public function set value(value:String):void
		{
			_value = parseDate(value.toString());
		}

		public function toString():String 
		{
			var dateValue:Date = new Date(parseInt(value.substr(0,4)),parseInt(value.substr(4,2)),parseInt(value.substr(6)));
			
			var month:String;
			var date:String;
			
			month = dateValue.month < 10 ?  "0" + dateValue.month: dateValue.month.toString();
			date = dateValue.date < 10 ? "0" + dateValue.date : dateValue.date.toString();
			
			if (dateValue.fullYear < 1900)
				return "";
			
			return date + "/" + month + "/" + dateValue.fullYear.toString();
		}
		
		public function parseDate(input:String):String
		{
			var month:String;
			var date:String;
			


			var inputArray:Array = input.split("-/");
			var inputYear:Number = parseInt(input.substring(0,4));
			var inputMonth:Number = parseInt(input.substring(5,7));
			var inputDay:Number = parseInt(input.substring(9));
			
			month = inputMonth < 10 ?  "0" + inputMonth : inputMonth.toString();
			date = inputDay < 10 ? "0" + inputDay : inputDay.toString();
			
			return inputYear + month + date;
			
		}
		
		
		
	}
}